<extend name="Public/base"/>

<block name="body">
    <style type="text/css">
    
    </style>

    <!-- 
        button a 标签的按钮 需要加入 class="btn btn-default" 
            删除加入 btn-danger 确认加入 btn-success;  
            h2标题后面添加返回的按钮

    

        form 表单内 所有项目需加入 form-control 
            使用input-small input-large 控制宽度 
            textarea 使用 rows="" 控制高度
            一个填写组外div 添加 form-group
            提交按钮组 外div 添加 form-action row; 添加一个外部div class="col-xs-3" 控制提交按钮宽度

            radio 的label添加 radio-inline
            checkbox 同样
        

        切换按钮组 外添加 nav-tabs


    -->

    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <div class="main-title">
        <h2>商品管理 <button class="btn btn-default btn-return" onclick="javascript:history.back(-1);return false;"><i class="glyphicon glyphicon-share-alt"></i> 返 回</button></h2>
    </div>

    <div class="tab-content">
    <form action="" method="post" class="form">
            <div class="form-item form-group">
                <label class="item-label">标题<span class="check-tips"></span></label>
                <div class="controls">
                    <input type="text" class="form-control text input-large" name="name" value="{$name|htmlspecialchars_decode}" />
                </div>
            </div>

            <div class="form-item form-group">
                <label class="item-label">搜索tag<span class="check-tips"> ( 用于搜索使用 不用写游戏 选择了游戏会自动加入 用,分割 )</span></label>
                <div class="controls">
                    <input type="text" class="form-control text input-large" name="search_key" value="{$search_key}" />
                </div>
            </div>

            <div class="form-item form-group">
                <label class="item-label">游戏<span class="check-tips"></span></label>
                <div class="controls">
                    <select class="form-control" id="game_id" name="game_id">
                        <option value="0">---请选择---</option>
                        <volist name="options.game_id" id="op">
                        <option value="{$key}">{$op}</option>
                        </volist>
                    </select>
                </div>
            </div>

            <div class="form-item form-group">
                <label class="item-label">原价<span class="check-tips"> ( 请输入整数 )</span></label>
                <div class="controls">
                    <input type="text" class="form-control text input-mini" name="oprice" value="{$oprice}" />
                </div>
            </div>

            <div class="form-item form-group">
                <label class="item-label">价格<span class="check-tips"> ( 请输入整数 )</span></label>
                <div class="controls">
                    <input type="text" class="form-control text input-mini" name="price" value="{$price}" />
                </div>
            </div>

            <div class="form-item form-group">
                <label class="item-label">兑换失效时间<span class="check-tips"> ( 购买商品后该时间内未兑换 则自动失效. 默认写入3天 259200 )</span></label>
                <div class="controls">
                    <input type="text" class="form-control text input-mini" name="expire_in" value="{$expire_in|default=259200}" />
                </div>
            </div>

            <div class="form-item form-group">
                <label class="item-label">排序<span class="check-tips"> 数值越大越靠前(0~127)</span></label>
                <div class="controls">
                    <input type="text" class="form-control text input-mini" name="recommend" value="{$recommend}" />
                </div>
            </div>

           <!--  <div class="form-item form-group">
                <label class="item-label">商品自动下架时间<span class="check-tips"> ( 商品在此时间会自动下架 之后停止购买 不填写则不自动下架)</span></label>
                <div class="controls">
                    <input type="text" class="form-control text input-small time" name="expire_at" value="{$expire_at}" />
                </div>
            </div> -->


            <div class="form-item form-group">
                <label class="item-label">缩略图<span class="check-tips">(480*270 jpg)</span></label>
                <div class="controls">
                    <input type="file" id="upload_picture_thumb">
                    <input type="hidden" class="text input-large" name="thumb" id="cover_id_thumb" value="{$thumb}" />
                    <div class="upload-img-box">
                    <notempty name="thumb">
                        <div class="upload-pre-item"><img class="img-thumbnail" src="{:url_format($thumb)}"/></div>
                    </notempty>
                    </div>
                </div>   
                <script type="text/javascript">
                //上传图片
                /* 初始化上传插件 */
                $("#upload_picture_thumb").uploadify({
                    "height"          : 30,
                    "swf"             : "__STATIC__/uploadify/uploadify.swf",
                    "fileObjName"     : "download",
                    "buttonText"      : "上传图片",
                    "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
                    "width"           : 120,
                    'removeTimeout'   : 1,
                    'fileTypeExts'    : '*.jpeg; *.jpg; *.png; *.gif;',
                    "onUploadSuccess" : uploadpicturethumb,
                    'onFallback' : function() {
                        alert('未检测到兼容版本的Flash.');
                    }
                });
                function uploadpicturethumb(file, data){
                    var data = $.parseJSON(data);
                    var src = '';
                    if(data.status){
                        $("#cover_id_thumb").val(data.path);
                        src = data.url || '__ROOT__' + data.path
                        $("#cover_id_thumb").parent().find('.upload-img-box').html(
                            '<div class="upload-pre-item"><img src="' + src + '"/></div>'
                        );
                    } else {
                        updateAlert(data.info);
                        setTimeout(function(){
                            $('#top-alert').find('button').click();
                            $(that).removeClass('disabled').prop('disabled',false);
                        },1500);
                    }
                }
                </script>
            </div>
          
            <div class="form-item form-group">
                <label class="item-label">描述<span class="check-tips"></span></label>
                <div class="controls">
                    <label class="input-large">
                        <input type="hidden" name="content[0][key]" value="detail">
                        <textarea class="textarea form-control" rows="3" name="content[0][description]">{$content[0]['description']|htmlspecialchars_decode}</textarea>
                    </label>
                </div>
            </div>

            <div class="form-item form-group">
                <label class="item-label">说明<span class="check-tips"></span></label>
                <div class="controls">
                    <label class="input-large">
                        <input type="hidden" name="content[1][key]" value="explain">
                        <textarea class="textarea form-control" rows="3" name="content[1][description]">{$content[1]['description']|htmlspecialchars_decode}</textarea>
                    </label>
                </div>
            </div>

            <div class="form-item form-group">
                <label class="item-label">流程<span class="check-tips"></span></label>
                <div class="controls">
                    <label class="input-large">
                        <input type="hidden" name="content[2][key]" value="flow">
                        <textarea class="textarea form-control" rows="3" name="content[2][description]">{$content[2]['description']|htmlspecialchars_decode}</textarea>
                    </label>
                </div>
            </div>

            <div class="form-item form-group">
                <label class="item-label">状态<span class="check-tips"></span></label>
                <label class="radio-inline" >
                    <input type="radio" name="status" value="1"  /> 开启
                </label>
                <label class="radio-inline">
                    <input type="radio" name="status" value="0"  /> 关闭
                </label>
            </div>

        </div>


        <div class="form-item form-action">
            <input type="hidden" name="id" value="{$id}" />
            <button class="btn submit-btn ajax-post btn-success btn-block" id="submit" type="submit" target-form="form">确 定</button>
        </div>
    </form>
    </div>
    <div id="video-pre">
        <video controls="controls" autoplay="autoplay"></video>
    </div>
</block>

<block name="script">
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>
    <script type="text/javascript" src="__STATIC__/knockout-2.3.0.js"></script>
    <link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
    <php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
    <link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
    <script type="text/javascript">
        //导航高亮
        highlight_subnav('{:U('Video/index')}');
        showTab();
         
 
        Think.setValue("type", '{$type}');
        Think.setValue("status", '{$status|default=1}');
        Think.setValue("game_id", '{$game_id}');
        Think.setValue("page", '{$page}');
        $('.time').datetimepicker({
                format: 'yyyy-mm-dd hh:ii',
                language:"zh-CN",
                minView:0,
                autoclose:true
            });
    </script>
</block>
